package iconSwingStates.Transitions;

import iconSwingStates.Event.EVirtualIConEvent;
import fr.lri.swingstates.sm.transitions.Event;

/**
 * TGeneric is the top level of the transition hierarchies. We set here the bases of all the other transitions
 * @author uribe-gaget
 *
 */
public class TGeneric extends Event{
	/**
	 * If the slots must be connected or not
	 */
	private boolean obligatory = false;
	/**
	 * If the slots must be active in the same time or not
	 */
	private boolean synchro = false;
	/**
	 * The name of the transition
	 */
	private String name;
	/**
	 * Kind of slots associated with this transition
	 */
	private int[] types = new int[1];

	/**
	 * Constructor for the transitions needing one slot and where the output state is different from the input state
	 * @param name Name of the transition
	 * @param type Types of slots
	 * @param obligatory If the slot must be connected or not
	 * @param synchro  If the slot must be active or not
	 * @param outputState The output state
	 */
	public TGeneric(String name, int[] type,boolean obligatory,boolean synchro,String outputState) {
		super(name, outputState);
		this.obligatory = obligatory;
		this.synchro = synchro;
		this.name = name;
		types = type;
	}
	/**
	 * Constructor for the transitions needing more than one slot and where the output state is the same as the input state
	 * @param name Name of the transition
	 * @param type Types of slots
	 * @param obligatory If the slot must be connected or not
	 * @param synchro  If the slot must be active or not
	 */
	public TGeneric(String name,int[] type,boolean obligatory,boolean synchro) {
		super(name);
		this.obligatory = obligatory;
		this.synchro = synchro;
		this.name = name;
		types = type;
	}

	/**
	 * Constructor for the transitions needing one slot and where the output state is the same as the input state
	 * @param name Name of the transition
	 * @param type Type of the slot
	 * @param obligatory If the slot must be connected or not
	 * @param synchro  If the slot must be active or not
	 */
	public TGeneric(String name,int type,boolean obligatory,boolean synchro) {
		super(name);
		this.obligatory = obligatory;
		this.synchro = synchro;
		this.name = name;
		types[0] = type;
	}


	/**
	 * Constructor for the transitions needing one slot and where the output state is different from the input state
	 * @param name Name of the transition
	 * @param type Type of the slot
	 * @param obligatory If the slot must be connected or not
	 * @param synchro  If the slot must be active or not
	 * @param outputState The output state
	 */
	public TGeneric(String name,int type,boolean obligatory,boolean synchro, String outputState) {
		super(name,outputState);
		this.obligatory = obligatory;
		this.synchro = synchro;
		this.name = name;
		types[0] = type;
	}

	/**
	 * Constructor using only the name of the transition and where the output state is different from the input state
	 * @param name The name of the transition
	 * @param outputState the output state
	 */
	public TGeneric(String name, String outputState) {
		super(name,outputState);
		this.obligatory = false;
		this.name = name;
		types = null;
	}

	/**
	 * Constructor using only the name of the transition and where the output state is the same as the input state
	 * @param name The name of the transition
	 */
	public TGeneric(String name) {
		super(name);
		this.obligatory = false;
		this.name = name;
		types = null;
	}

	/**
	 * Constructor used when there is no pointer needed
	 * @param name Name of the transition
	 * @param type Type of the slot
	 * @param obligatory True if the slot must be connected
	 */
	public TGeneric(String name,int type,boolean obligatory) {
		super(name);
		this.obligatory = false;
		this.name = name;
		types[0] = type;
	}
	/**
	 * Constructor used when there is no pointer needed
	 * @param name Name of the transition
	 * @param type Type of the slot
	 * @param obligatory True if the slot must be connected
	 * @param outputState The output state
	 */
	public TGeneric(String name,int type,boolean obligatory, String outputState) {
		super(name,outputState);
		this.obligatory = false;
		this.name = name;
		types[0] = type;
	}
	
	/**
	 * Indicates if all the slots must be connected
	 * @return true if all the slots must be connected
	 */
	public boolean isObligatory(){
		return obligatory;
	}

	/**
	 * Indicates if all the slots must be active in the same time or not
	 * @return true if all the slots must be active in the same time
	 */
	public boolean isSynchro(){
		return synchro;
	}
	/**
	 * Return the name of the transition
	 * @return the name of the transition
	 */
	public String getName(){
		return name;
	}

	/**
	 * Get the types of slots
	 * @return an array with the types of slots
	 */
	public int[] getSourcesTypes() {
		return types;
	}

	@Override
	public EVirtualIConEvent getEvent() {
		return (EVirtualIConEvent) super.getEvent();
	}  
}
